package indi.mumu.validator;

import indi.mumu.common.model.Clothes;
import indi.mumu.common.model.Saleorder;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class SaleValidator extends Validator{
	protected void validate(Controller controller) {
		validateRequiredString("saleorder.saleOrder_id", "saleOrderIdMsg", "请输入订单ID!");
		validateRequiredString("saleorder.saleDateTime", "saleDateTimeMsg", "请输入下单时间!");
		validateRequiredString("saleorder.Total", "totalMsg", "请输入订单总金额!");
		validateRequiredString("saleorder.stuff", "stuffMsg", "请输入收银员工号!");
	}
	
	protected void handleError(Controller controller) {
		controller.keepModel(Saleorder.class);
		
		String actionKey = getActionKey();
		if (actionKey.equals("/sell/save"))
			controller.render("add.html");
		else if (actionKey.equals("/sell/update"))
			controller.render("edit.html");
		else if (actionKey.equals("/sell/getClothesByBarcode"))
			controller.render("search.html");
	}
}
